package com.oa.modules.approvalsec1.controller;

import java.util.Arrays;
import java.util.Map;

import com.oa.common.utils.AppUtils;
import com.oa.modules.approvalsec1.entity.InstitutionsMattersEntity;
import com.oa.modules.approvalsec1.service.InstitutionsMattersService;
import com.oa.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.oa.common.utils.PageUtils;
import com.oa.common.utils.R;



/**
 * 机构事项
 * @author Hankaicheng
 * @email 785297226@qq.com
 * @date 2022-05-05 15:23:15
 */

@RestController
@RequestMapping("/institutionsmatters")
@Api(tags = "机构事项相关接口")
public class InstitutionsMattersController extends AbstractController {
    @Autowired
    private InstitutionsMattersService institutionsMattersService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表")
    @RequiresPermissions("generator:institutionsmatters:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = institutionsMattersService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation(value = "信息")
    @RequiresPermissions("generator:institutionsmatters:info")
    public R info(@PathVariable("id") Integer id){
		InstitutionsMattersEntity institutionsMatters = institutionsMattersService.getById(id);
        return R.ok().put("institutionsMatters", institutionsMatters);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存")
    @RequiresPermissions("generator:institutionsmatters:save")
    public R save(@RequestBody InstitutionsMattersEntity institutionsMatters){
		institutionsMattersService.save(institutionsMatters);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改")
    @RequiresPermissions("generator:institutionsmatters:update")
    public R update(@RequestBody InstitutionsMattersEntity institutionsMatters){
		institutionsMattersService.updateById(institutionsMatters);
        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    @RequiresPermissions("generator:institutionsmatters:delete")
    public R delete(@RequestBody Integer[] ids){
		institutionsMattersService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
